<script lang="ts" setup>
import { truncate } from "fs";

const props = defineProps({
  modelValue: {
    type: String,
    default: "",
  },
  tips: {
    type: String,
    default: "",
  },
  name: {
    type: String,
    default: "颜色",
  },
});

const emits = defineEmits(["update:modelValue", "change"]);

const onChange = (value: any) => {
  emits("update:modelValue", value);
  emits("change", value);
};
</script>
<template>
  <el-form-item :label="name">
    <template #label>
      <div class="flex-container">
        <span>{{ name }}</span>
        <template v-if="tips">
          <el-tooltip effect="dark" :content="tips" placement="top">
            <el-icon><InfoFilled /></el-icon>
          </el-tooltip>
        </template>
      </div>
    </template>
    <el-color-picker
      :model-value="modelValue"
      @change="onChange"
    ></el-color-picker>
  </el-form-item>
</template>
<style lang="scss" scoped>
.flex-container {
  display: flex;
  align-items: center;
  .el-icon {
    cursor: pointer;
  }
}
</style>
